package com.hsc.www;

import com.hsc.www.common.CheckToken;
import com.hsc.www.common.OAuthUtil;
import com.hsc.www.common.Token;
import com.hsc.www.common.TokenKey;

/**
 * Hello world!
 */
public class App {
    public static void main(String[] args) throws Exception {


        OAuthUtil oAuthUtil = new OAuthUtil("http://127.0.0.1:8081", "client1", "secret1");

        TokenKey tokenKey = oAuthUtil.getTokenKey();
        System.out.println("获取tokenKey=" + tokenKey.toString());


        Token token = oAuthUtil.getToken("admin", "123456", "www.baidu.com");
        System.out.println("获取token=" + token.toString());

        CheckToken checkToken = oAuthUtil.getCheckToken(token.getAccess_token());
        System.out.println("获取checkToken=" + checkToken.toString());


        String s1 = oAuthUtil.loadResourceByGet(token.getAccess_token(), token.getToken_type(), "http://127.0.0.1:8082/adminSource", String.class);
        System.out.println("获取资源:" + s1);



    }
}
